﻿// (c) Copyright 2013 Mike Riedel.
// This source is subject to the Microsoft Public License (Ms-PL).
// All other rights reserved.

using System;

namespace FreshMeat.Storage
{
   /// <summary>
   /// Respository that stores its data in memory, yielding excellent performance but with no durability.
   /// </summary>
   /// <typeparam name="TId"></typeparam>
   /// <typeparam name="TItem"></typeparam>
   public class MemoryRepository<TId, TItem> : Repository<TId, TItem, TItem>
   {
      /// <summary>
      /// Creates instance.
      /// </summary>
      /// <param name="idGetter">Function which gets an item's ID.</param>
      /// <param name="serializer">Serializer to be used.</param>
      public MemoryRepository(Func<TItem, TId> idGetter, ISerializer<TItem> serializer)
         : base(new IdentityMapper<TId, TItem>(idGetter), new MemoryStore<TId, TItem>(serializer))
      {
      }
   }
}